package TeachLesson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

@WebServlet(name = "updateSolveProServlet")
public class updateSolveProServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       SolveProDao solveProDao=new SolveProDao();
       String title=request.getParameter("title");
       String realText=request.getParameter("realText");
       int titleID=Integer.parseInt(request.getParameter("titleID"));

       int row=solveProDao.updateSolvePro(titleID,title,realText);
       if(row>0){
           response.sendRedirect("/Teachers/SolveText.jsp?&titleID="+ URLEncoder.encode(request.getParameter("titleID"),"UTF-8")+"&title="+URLEncoder.encode(title,"UTF-8")+"&realText="+URLEncoder.encode(realText,"UTF-8"));
       }else {
           response.getWriter().println("修改失败请后退重试");
       }
    }
}
